﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UINameDef
{
    public const string MainPanel = "Prefabs/MainPanel";
    public const string LoginPanel = "Prefabs/LoginPanel";
    public const string PackagePanel = "Prefabs/PackagePanel";
}



public class UIManager : Singleton<UIManager>
{

    public Dictionary<string, GameObject> UIDict = new Dictionary<string, GameObject>();

    public void CreateUIByName(string panelName,bool setatfirsting = true)
    {
        GameObject go = null;
        if (!UIDict.TryGetValue(panelName, out go))
        {
            GameObject goes = ResourceManager.Instance.LoadAsset<GameObject>(panelName);
            go = GameObject.Instantiate(goes, MainGameManager.Instance.UIRoot.transform);
            go.SetActive(true);
            UIDict.Add(panelName, go);
        }
        else
        {
            go = UIDict[panelName];
            if (setatfirsting)
            {
                go.transform.SetAsFirstSibling();
            }
        }
    }

    
	
}
